The code below assumes that a PrintJob is already open.
PEGetNTables PEGetNthTableLocation PESetNthTableLocation
uses CRDelphi; procedure GetTableLocation; var TableLoc : PETableLocation; nTable : smallint; nTables : smallint; sName, sPath : string; begin TableLoc.StructSize := SizeOf(PETableLocation); {Get number of tables} nTables := PEGetNTables(PrintJob); if nTables =-1 then {Do Error Handler}; {Loop through the tables} for nTable := 0 to (nTables - 1) do begin {Get table location} if not PEGetNthTableLocation(PrintJob, nTable, TableLoc) then {Do Error Handler}; sName := ExtractFileName(StrPas(@TableLoc.Location)); sPath := ExtractFilePath(StrPas(@TableLoc.Location)); end; end; {PESetNthTableLocation can be used to change the Table Path, Table Name, or both. In this example the Path is changed} procedure SetTableLocation; var TableLoc : PETableLocation; nTables : smallint; nTable : smallint; sName, sPath : string; sTmp : string; begin TableLoc.StructSize := SizeOf(PETableLocation); {Set New Path} sPath := 'C:\NewDir\'; {Get the number of Tables} nTables := PEGetNTables(PrintJob); if nTables =-1 then {Do Error Handler}; {Loop through the items} for nTable := 0 to (nTables - 1) do begin {Get table location} if not PEGetNthTableLocation(PrintJob, nTable, TableLoc) then {Do Error Handler}; {Get the current Table Name} sName := ExtractFileName(StrPas(@TableLoc.Location)); {Join the Current Table Name & New Path} sTmp := sPath + sName; {Send in the new Table location/name} StrPCopy(@TableLoc.Location, sTmp); if not PESetNthTableLocation(PrintJob, nTable, TableLoc) then {Do Error Handler}; end; end;
Seagate Software IMG Holdings, Inc. http://www.seagatesoftware.com Support services: http://support.seagatesoftware.com |